#ifndef __THREADPOOL_H_
#define __THREADPOOL_H_

#include <pthread.h>
#include <sched.h>
#include <semaphore.h>
#include <vector>
#include <queue>

#include "Worker.h"
#include "../../API/Common/Typedefs.h"
#include "../../API/Tasks/_Task.h"

namespace skelepp {
	namespace Core {
		namespace Tasking {
			class ThreadPool {
			private:
				pthread_t _worker;
				pthread_mutex_t _lock;

				static void *_distribute(void *data) {
					ThreadPool *p = (ThreadPool *)data;
					p->distribute();
					return 0;
				}

				void distribute(void);
				
				vector<Worker *> _workers;
				
				queue<_Task *> _low_queue;
				queue<_Task *> _normal_queue;
				queue<_Task *> _high_queue;
			public:
				ThreadPool(uint32_t threads);
				~ThreadPool(void);
			
				void perform(_Task *task);
			};
		}
	}
}

#endif